import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index/index'
import all from '@/components/all/index.vue'
import kf from '@/components/all/kf.vue'
import help from '@/components/all/help.vue'
import jiaoliu from '@/components/all/jiaoliu.vue'
import gonggao from '@/components/all/gonggao.vue'
import shoplist from '@/components/all/shoplist.vue'
import chat from '@/components/all/chat.vue'
//帖子页
import postdetail from '@/components/post/postdetail.vue'
//商品页
import fooddetail from '@/components/shop/fooddetail.vue'
import pay from '@/components/shop/pay.vue'
import paysuccess from '@/components/shop/paysuccess.vue'
import evaluate from '@/components/shop/evaluate.vue'
//个人中心页面
import user from '@/components/user/index.vue'
import address from '@/components/user/address.vue'
import shopcar from '@/components/user/shopcar.vue'
import myorder from '@/components/user/myorder.vue'

Vue.use(Router)

export default new Router({
  routes: [
    //首页
    {
      path: '/',
      name: 'index',
      component: index
    },
    //所有页面
   	{
      path: '/all',
      name: 'all',
      component: all
    },
    //在线客服
    {
      path: '/kf',
      name: 'kf',
      component: kf
    },
    //帮助 
    {
      path: '/help',
      name: 'help',
      component: help
    },
    //交流
    {
      path: '/jiaoliu',
      name: 'jiaoliu',
      component: jiaoliu
    },
    //公告
    {
      path: '/gonggao',
      name: 'gonggao',
      component: gonggao
    },
    //商品首页
    {
      path: '/shoplist',
      name: 'shoplist',
      component: shoplist
    },
    //聊天室
    {
      path: '/chat',
      name: 'chat',
      component: chat
    },
    //帖子详情
    {
      path:'/postdetail/:pid',
      name:'postdetail',
      component:postdetail
    },
    //食物详情
    {
      path:'/fooddetail/:fid',
      name:'fooddetail',
      component:fooddetail
    },
    //支付流程
    {
      path:'/pay/:flow/:fid/:uid/:num',
      name:'pay',
      component:pay
    }, 
    //支付完成
    {
      path:'/paysuccess',
      name:'paysuccess',
      component:paysuccess
    }, 
    //商品评价
    {
      path:'/evaluate/:fid',
      name:'evaluate',
      component:evaluate,
      meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      }
    }, 
    //个人中心首页
    {
      path:'/user/index',
      name:'user',
      component:user,
      meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      }
    }, 
    //地址列表
    {
      path:'/user/address',
      name:'address',
      component:address,
      meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      }
    }, 
    //购物车
    {
      path:'/user/shop_car',
      name:'shopcar',
      component:shopcar,
      meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      }
    }, 
    //我的订单
    {
      path:'/user/myorder',
      name:'myorder',
      component:myorder,
      meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      }
    }, 
    //错误地址
    {
      path:'/:error',
      name:'error',
      redirect: { name: 'index' }
    }
  ]
})
